<?php

class teacher_Form_FrmAvaliableTime extends Zend_Form
{

    public function init()
    {
    }
    public function avaliableFilter(){
    	$db = new Application_Model_DbTable_DbGlobal();
    	$request=Zend_Controller_Front::getInstance()->getRequest();
    	$teacher_name = new Zend_Form_Element_Text("teacher_name");
    	$teacher_name->setAttribs(array('id'=>'teacher_name','class'=>'form-control'));
    	
    	$academic = new Zend_Form_Element_Text("academic");
    	$academic->setAttribs(array('id'=>'academic','class'=>'form-control validate[required]'));
    	$value_academic= $request->getParam("academic");
    	$academic->setValue($value_academic);
    	
    	$semester = new Zend_Form_Element_Select("semester");
    	$semester->setAttribs(array('id'=>'semester','class'=>'form-control validate[required]'));
    	$opt_semester = array(''=>"Please Select Semester",1=>"Semester I",2=>"Semester II");
    	$value_semester= $request->getParam("semester");
    	$semester->setValue($value_semester);
    	//$semester->setAttribs(array("class"=>"form-control validate[required]"));
    	$semester->setMultiOptions($opt_semester);
    
    	$day = new Zend_Form_Element_Select("day");
    	$day->setAttribs(array('id'=>'day','class'=>'form-control'));
    	$rs=$db->getGlobalDb('SELECT * FROM tbl_day WHERE day_name!=""');
    	$opt_day="";
    	$opt_day=array(''=>'Please Select','-1'=>'Add New Teacher');
    	if(!empty($rs)) foreach($rs as $read) $opt_day[$read['day_id']]=$read['day_name'];
    	;
    	$day->setMultiOptions($opt_day);
    
    	$time = new Zend_Form_Element_Select("time");
    	$time->setAttribs(array('id'=>'time','class'=>'form-control'));
    	$rs_time=$db->getGlobalDb('SELECT * FROM tbl_time WHERE time_name!=""');
    	$opt_time="";
    	$opt_time=array(''=>'Please Select');
    	if(!empty($rs_time)) foreach($rs_time as $read) $opt_time[$read['time_id']]=$read['time_name'];
    	$time->setMultiOptions($opt_time);
    	
    	$department = new Zend_Form_Element_Select("department");
    	$department->setAttribs(array('id'=>'department','class'=>'form-control'));
    	$rs_department=$db->getGlobalDb('SELECT * FROM tbl_departments WHERE dpt_name!=""');
    	$opt_deparment="";
    	$opt_deparment=array(''=>'Please Select');
    	if(!empty($rs_department)) foreach($rs_department as $read) $opt_deparment[$read['dpt_id']]=$read['dpt_name'];
    	$department->setMultiOptions($opt_deparment);
    	$value_dpt= $request->getParam("department");
    	$department->setValue($value_dpt);
    	$this->addElement($department);
    
    	$this->addElements(array($teacher_name,$academic,$semester,$day,$time));
    	return $this;
    }
    public function addAvaliabletime($data=null){
    	$db = new Application_Model_DbTable_DbGlobal();
    	$lecturer = new Zend_Form_Element_Text("leacturer");
    	$lecturer->setAttribs(array("class"=>"form-control validate[required]"));
    	
    	$id_code = new Zend_Form_Element_Text("id_code");
    	$id_code->setAttribs(array("class"=>"form-control validate[required]"));
    	$this->addElement($id_code);
    	
    	$rs=$db->getGlobalDb('SELECT teacher_id, teacher_name FROM tbl_teacher WHERE teacher_id!=""');
    	$options="";
    	$options=array(''=>'Please Select','-1'=>'Add New Teacher');
    	if(!empty($rs)) foreach($rs as $read) $options[$read['teacher_id']]=$read['teacher_name'];
    	$teacher = new Zend_Form_Element_Select("teacher");
    	$teacher->setMultiOptions($options);
    	$teacher->setAttribs(array("class"=>"form-control validate[required]"));
    	
    	$subject = new Zend_Form_Element_Text("subject");
    	$subject->setAttribs(array("class"=>"form-control validate[required]"));
    	
    	$tel = new Zend_Form_Element_Text("tel");
    	$tel->setAttribs(array("class"=>"form-control validate[required]"));
    	
    	$email = new Zend_Form_Element_Text("email");
    	$email->setAttribs(array("class"=>"form-control validate[required]"));
    	
    	$submit = new Zend_Form_Element_Submit("Save");
    	$submit->setAttribs(array("class"=>"form-control"));
    	
    	$_id = new Zend_Form_Element_Hidden('id');
    	
    	$academic = new Zend_Form_Element_Text("academic_year");
    	$academic->setAttribs(array("class"=>"form-control validate[required]","placeholder"=>"Academic year"));
    	$this->addElement($academic);
    	
    	$semester = new Zend_Form_Element_Select("semester");
    	$opt_semester = array(""=>"please Select Semester",1=>"Semester I",2=>"Semester II");
    	$semester->setMultiOptions($opt_semester);
    	$semester->setAttribs(array("class"=>"form-control validate[required]"));
    	$this->addElement($semester);
  
    	$check1 = new Zend_Form_Element_Checkbox("check_7_8_mon");
    	$check2 = new Zend_Form_Element_Checkbox("check_7_8_tur");
    	$check3 = new Zend_Form_Element_Checkbox("check_7_8_wed");
    	$check4 = new Zend_Form_Element_Checkbox("check_7_8_thu");
    	$check5 = new Zend_Form_Element_Checkbox("check_7_8_fri");
    	$check6 = new Zend_Form_Element_Checkbox("check_7_8_sat");
    	$check7 = new Zend_Form_Element_Checkbox("check_7_8_sun");
    	
    	$check8 = new Zend_Form_Element_Checkbox("check_8_10_mon");
    	$check9 = new Zend_Form_Element_Checkbox("check_8_10_tur");
    	$check10 = new Zend_Form_Element_Checkbox("check_8_10_wed");
    	$check11 = new Zend_Form_Element_Checkbox("check_8_10_thu");
    	$check12 = new Zend_Form_Element_Checkbox("check_8_10_fri");
    	$check13 = new Zend_Form_Element_Checkbox("check_8_10_sat");
    	$check14 = new Zend_Form_Element_Checkbox("check_8_10_sun");
    	
    	$check15 = new Zend_Form_Element_Checkbox("check_10_12_mon");
    	$check16 = new Zend_Form_Element_Checkbox("check_10_12_tur");
    	$check17 = new Zend_Form_Element_Checkbox("check_10_12_wed");
    	$check18 = new Zend_Form_Element_Checkbox("check_10_12_thu");
    	$check19 = new Zend_Form_Element_Checkbox("check_10_12_fri");
    	$check20 = new Zend_Form_Element_Checkbox("check_10_12_sat");
    	$check21 = new Zend_Form_Element_Checkbox("check_10_12_sun");
    	
    	$check22 = new Zend_Form_Element_Checkbox("check_1_2_mon");
    	$check23 = new Zend_Form_Element_Checkbox("check_1_2_tur");
    	$check24 = new Zend_Form_Element_Checkbox("check_1_2_wed");
    	$check25 = new Zend_Form_Element_Checkbox("check_1_2_thu");
    	$check26 = new Zend_Form_Element_Checkbox("check_1_2_fri");
    	$check27 = new Zend_Form_Element_Checkbox("check_1_2_sat");
    	$check28 = new Zend_Form_Element_Checkbox("check_1_2_sun");
    	
    	$check29 = new Zend_Form_Element_Checkbox("check_2_4_mon");
    	$check30 = new Zend_Form_Element_Checkbox("check_2_4_tur");
    	$check31 = new Zend_Form_Element_Checkbox("check_2_4_wed");
    	$check32 = new Zend_Form_Element_Checkbox("check_2_4_thu");
    	$check33 = new Zend_Form_Element_Checkbox("check_2_4_fri");
    	$check34 = new Zend_Form_Element_Checkbox("check_2_4_sat");
    	$check35 = new Zend_Form_Element_Checkbox("check_2_4_sun");
    	
    	$check36 = new Zend_Form_Element_Checkbox("check_4_5_mon");
    	$check37 = new Zend_Form_Element_Checkbox("check_4_5_tur");
    	$check38 = new Zend_Form_Element_Checkbox("check_4_5_wed");
    	$check39 = new Zend_Form_Element_Checkbox("check_4_5_thu");
    	$check40 = new Zend_Form_Element_Checkbox("check_4_5_fri");
    	$check41 = new Zend_Form_Element_Checkbox("check_4_5_sat");
    	$check42 = new Zend_Form_Element_Checkbox("check_4_5_sun");
    	
    	$check43 = new Zend_Form_Element_Checkbox("check_5_7_mon");
    	$check44 = new Zend_Form_Element_Checkbox("check_5_7_tur");
    	$check45 = new Zend_Form_Element_Checkbox("check_5_7_wed");
    	$check46 = new Zend_Form_Element_Checkbox("check_5_7_thu");
    	$check47 = new Zend_Form_Element_Checkbox("check_5_7_fri");
    	$check48 = new Zend_Form_Element_Checkbox("check_5_7_sat");
    	$check49 = new Zend_Form_Element_Checkbox("check_5_7_sun");
    	
    	$check50 = new Zend_Form_Element_Checkbox("check_7_8_1_mon");
    	$check51 = new Zend_Form_Element_Checkbox("check_7_8_1_tur");
    	$check52 = new Zend_Form_Element_Checkbox("check_7_8_1_wed");
    	$check53 = new Zend_Form_Element_Checkbox("check_7_8_1_thu");
    	$check54 = new Zend_Form_Element_Checkbox("check_7_8_1_fri");
    	$check55 = new Zend_Form_Element_Checkbox("check_7_8_1_sat");
    	$check56 = new Zend_Form_Element_Checkbox("check_7_8_1_sun");
    	
    	
    	
    	$this->addElements(array($lecturer,$teacher,$subject,$tel,$email,$check1,$check2,$check3,$check4,
    			$check5,$check6,$check7,$check8,$check9,$check10,$check11,$check12,$check13,$check14,
    			$check15,$check16,$check17,$check18,$check19,$check20,$check21,$check21,$check22,$check23
    			,$check24,$check25,$check26,$check27,$check28,$check29,$check30,$check31,$check32,$check33,
    			$check34,$check35,$check36,$check37,$check38,$check39,$check40,$check41,$check42,$check43,
    			$check44,$check45,$check46,$check47,$check48,$check49,$check50,$check51,$check52,$check54,$check53,
    			$check55,$check56,$submit
    			));
// $this->addElements(array($lecturer,$subject,$tel,$email,$submit,$mon_7_8,$mon_8_10,$mon_7_8_1,$mon_10_12,$mon_1_2,$mon_2_4,$mon_4_5,$mon_5_7
// 					,$tur_8_10,$tur_7_8_1,$tur_7_8,$tur_5_7,$tur_4_5,$tur_2_4,$tur_1_2,$tur_10_12
// 					,$wed_8_10,$wed_7_8_1,$wed_7_8,$wed_5_7,$wed_4_5,$wed_2_4,$wed_1_2,$wed_10_12
// 					,$thu_8_10,$thu_7_8_1,$thu_7_8,$thu_5_7,$thu_4_5,$thu_2_4,$thu_1_2,$thu_10_12
// 					,$fri_8_10,$fri_7_8_1,$fri_7_8,$fri_5_7,$fri_4_5,$fri_2_4,$fri_1_2,$fri_10_12
// 					,$sat_8_10,$sat_7_8_1,$sat_7_8,$sat_5_7,$sat_4_5,$sat_2_4,$sat_1_2,$sat_10_12
// 					,$sun_8_10,$sun_7_8_1,$sun_7_8,$sun_5_7,$sun_4_5,$sun_2_4,$sun_1_2,$sun_10_12			
// 		));

		if(!empty($data)){
			
			$id = new Zend_Form_Element_Hidden('id');
			$this->addElement($id);
			$id->setValue($data["avaliable_id"]);
			
			$ids = new Zend_Form_Element_Hidden('ids');
			$this->addElement($ids);
			$ids->setValue($data["id"]);
			
			$teacher->setValue($data["teacher_id"]);
			$academic->setValue($data["academic_year"]);
			$semester->setValue($data["semester_id"]);
			$id_code->setValue($data["id_code"]);
			$tel->setValue($data["tel"]);
			$email->setValue($data["email"]);
			
			if($data["mon_7_8"]){
				$check1->setChecked(true);
			}
			if($data["tur_7_8"]){
				$check2->setChecked(true);
			}
			if($data["wed_7_8"]){
				$check3->setChecked(true);
			}
			if($data["thu_7_8"]){
				$check4->setChecked(true);
			}
			if($data["fri_7_8"]){
				$check5->setChecked(true);
			}
			if($data["sat_7_8"]){
				$check6->setChecked(true);
			}
			if($data["sun_7_8"]){
				$check7->setChecked(true);
			}
			
			if($data["mon_8_10"]){
				$check8->setChecked(true);
			}
			if($data["tur_8_10"]){
				$check9->setChecked(true);
			}
			if($data["wed_8_10"]){
				$check10->setChecked(true);
			}
			if($data["thu_8_10"]){
				$check11->setChecked(true);
			}
			if($data["fri_8_10"]){
				$check12->setChecked(true);
			}
			if($data["sat_8_10"]){
				$check13->setChecked(true);
			}
			if($data["sun_8_10"]){
				$check14->setChecked(true);
			}
			
			if($data["mon_10_12"]){
				$check15->setChecked(true);
			}
			if($data["tur_10_12"]){
				$check16->setChecked(true);
			}
			if($data["wed_10_12"]){
				$check17->setChecked(true);
			}
			if($data["thu_10_12"]){
				$check18->setChecked(true);
			}
			if($data["fri_10_12"]){
				$check19->setChecked(true);
			}
			if($data["sat_10_12"]){
				$check20->setChecked(true);
			}
			if($data["sun_10_12"]){
				$check21->setChecked(true);
			}
			
			if($data["mon_1_2"]){
				$check22->setChecked(true);
			}
			if($data["tur_1_2"]){
				$check23->setChecked(true);
			}
			if($data["wed_1_2"]){
				$check24->setChecked(true);
			}
			if($data["thu_1_2"]){
				$check25->setChecked(true);
			}
			if($data["fri_1_2"]){
				$check26->setChecked(true);
			}
			if($data["sat_1_2"]){
				$check27->setChecked(true);
			}
			if($data["sun_1_2"]){
				$check28->setChecked(true);
			}
			
			if($data["mon_2_4"]){
				$check29->setChecked(true);
			}
			if($data["tur_2_4"]){
				$check30->setChecked(true);
			}
			if($data["wed_2_4"]){
				$check31->setChecked(true);
			}
			if($data["thu_2_4"]){
				$check32->setChecked(true);
			}
			if($data["fri_2_4"]){
				$check33->setChecked(true);
			}
			if($data["sat_2_4"]){
				$check34->setChecked(true);
			}
			if($data["sun_2_4"]){
				$check35->setChecked(true);
			}
			
			if($data["mon_4_5"]){
				$check36->setChecked(true);
			}
			if($data["tur_4_5"]){
				$check37->setChecked(true);
			}
			if($data["wed_4_5"]){
				$check38->setChecked(true);
			}
			if($data["thu_4_5"]){
				$check39->setChecked(true);
			}
			if($data["fri_4_5"]){
				$check40->setChecked(true);
			}
			if($data["sat_4_5"]){
				$check41->setChecked(true);
			}
			if($data["sun_4_5"]){
				$check42->setChecked(true);
			}
			
			
			if($data["mon_5_7"]){
				$check43->setChecked(true);
			}
			if($data["tur_5_7"]){
				$check44->setChecked(true);
			}
			if($data["wed_5_7"]){
				$check45->setChecked(true);
			}
			if($data["thu_5_7"]){
				$check46->setChecked(true);
			}
			if($data["tur_5_7"]){
				$check47->setChecked(true);
			}
			if($data["wed_5_7"]){
				$check48->setChecked(true);
			}
			if($data["thu_5_7"]){
				$check49->setChecked(true);
			}
			
			if($data["mon_7_8_1"]){
				$check50->setChecked(true);
			}
			if($data["tur_7_8_1"]){
				$check51->setChecked(true);
			}
			if($data["wed_7_8_1"]){
				$check52->setChecked(true);
			}
			if($data["thu_7_8_1"]){
				$check53->setChecked(true);
			}
			if($data["fri_7_8_1"]){
				$check54->setChecked(true);
			}
			if($data["sat_7_8_1"]){
				$check55->setChecked(true);
			}
			if($data["sun_7_8_1"]){
				$check56->setChecked(true);
			}
		}
    	return $this;
    }
}

